<html>

<head>
<title>Fragment Navigation Test.</title>
</head>

<body>
    <a href="#test-fragment">Test Fragment</a>
    <h1 id="visibility"></h1>
    <h1 id="fragment"></h1>
    <h1 id="initial-fragment"></h1>
    <script>
     var initialVisibility = "";
     window.onhashchange = function () {
         var hash = window.location.hash;
         document.getElementById("fragment").innerHTML = hash;
     }
     window.onload = function () {
         if (initialVisibility == "") {
             initialVisibility = document.visibilityState;
             document.getElementById("visibility").innerHTML = initialVisibility;
         }
         document.getElementById("initial-fragment").innerHTML = window.location.hash;
     }
    </script>
</body>
</html>
